refactor(core): introduce CommandContext for the queue+freeze prelude#1441
Merged
mergify[bot] merged 3 commits intoMay 27, 2026
Conversation
This was referenced May 19, 2026
Member
Author
|
This pull request is part of a Mergify stack:
|
This was referenced May 19, 2026
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 ⛓️ Depends-On RequirementsWonderful, this rule succeeded.Requirement based on the presence of
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
32628b4 to
d7feae3
Compare
32cbcd9 to
c542b1f
Compare
Member
Author
Revision history
|
d7feae3 to
bdea5bb
Compare
c542b1f to
141fec6
Compare
This was referenced May 26, 2026
beee2a7 to
d599400
Compare
This was referenced May 27, 2026
… Python Two coupled gaps the same user-visible bug was hiding: 1. The Rust binary never declared the top-level `--debug` flag the Python CLI accepts. Invocations like `mergify --debug ci git-refs` were rejected with `error: unexpected argument '--debug' found` the moment a command was promoted from shim to native. Add `debug: bool` as a `global = true` argument on `CliRoot`; native commands accept it as a no-op (no native code path consults the flag yet) and shimmed dispatches re-inject `--debug` at the front of the forwarded argv so the Python `cli` group still receives it. 2. The Python `cli.py` parsed `--debug` into `ctx.obj["debug"]` but never called `utils.set_debug(...)`, so the module-level `_DEBUG` toggle stayed `False` and the 6+ `if is_debug():` sites in `utils.py` / `stack/*` never fired regardless of the flag. Wire `set_debug(debug=debug)` from the root group so the flag has the effect users have always expected it to have. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Change-Id: I62ac941db12c55c988896086d7042c3dacf863af
Every command crate's test module re-rolled the same ~30 LOC of `SharedBytes` / `SharedWriter` / `Captured` / `make_output` glue — about 350 LOC of pure boilerplate across 15 files, drifting over time (some `Captured` had `stderr`, some didn't; one file even carried a `_stderr_accessor_lives` dead-code stub just to silence the resulting warning). Extract the canonical version into a new `mergify-test-support` crate that other crates pull in as a `dev-dependencies`. The new `Captured` API exposes `human()` / `new(mode)` constructors and `stdout()` / `stderr()` accessors, so the common pattern shrinks from a 12-line `String::from_utf8(cap.stdout.lock().unwrap().clone())` to `let s = cap.stdout()`. Net `-418 / +114` lines across the workspace. Behavior unchanged; all 233 tests pass. The crate is `publish = false` and only ever appears under `[dev-dependencies]`, so the test-only types never leak into a production build. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Change-Id: If9d688cdaf55360ba90f386d2020b52346c19b28
Every `queue` and `freeze` command opens with the same four-line
ritual: resolve repository slug, resolve token, resolve API URL,
build a Mergify-flavored HTTP client. Wrap those into a
`CommandContext::resolve(...)` constructor + `ctx.mergify_client()`
builder living in a new `mergify_core::command_context` module.
The eight queue/freeze command preludes shrink from
let repository = auth::resolve_repository(opts.repository)?;
let token = auth::resolve_token(opts.token)?;
let api_url = auth::resolve_api_url(opts.api_url)?;
let client = HttpClient::new(api_url, token, ApiFlavor::Mergify)?;
to
let ctx = CommandContext::resolve(opts.repository, opts.token, opts.api_url)?;
let client = ctx.mergify_client()?;
`auth::resolve_*` stay public for the specialized callers that
don't fit the shape: `config validate` needs no repository,
`config simulate` derives the repo from a PR URL, `ci scopes-send`
resolves the repo from CI-env vars (different fallback chain).
Those keep wiring up the lower-level helpers by hand.
Net `-73 / +63` across 9 files; conceptually the bigger win is
that "the prelude of a Mergify command" is now a named concept
with one fix-it-once point.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Change-Id: I1b272570f6802dd13438c3d9baf26709b196574d
d599400 to
5143191
Compare
Base automatically changed from
devs/jd/worktree-rust-port/share-test-scaffolding-via-mergify-test-support--f9d688cd
to
main
May 27, 2026 13:50
kozlek
approved these changes
May 27, 2026
sileht
approved these changes
May 27, 2026
Contributor
Merge Queue Status
This pull request spent 20 minutes 18 seconds in the queue, including 18 minutes 58 seconds running CI. Required conditions to merge
|
38 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every
queueandfreezecommand opens with the same four-lineritual: resolve repository slug, resolve token, resolve API URL,
build a Mergify-flavored HTTP client. Wrap those into a
CommandContext::resolve(...)constructor +ctx.mergify_client()builder living in a new
mergify_core::command_contextmodule.The eight queue/freeze command preludes shrink from
to
auth::resolve_*stay public for the specialized callers thatdon't fit the shape:
config validateneeds no repository,config simulatederives the repo from a PR URL,ci scopes-sendresolves the repo from CI-env vars (different fallback chain).
Those keep wiring up the lower-level helpers by hand.
Net
-73 / +63across 9 files; conceptually the bigger win isthat "the prelude of a Mergify command" is now a named concept
with one fix-it-once point.
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
Depends-On: #1439